    /**
* @param {Object} options 待分享的信息
* @p-config {String} appid 公众平台的appId（服务号可用）
* @p-config {String} shareImage 图片地址
* @p-config {String} shareLink 链接地址
* @p-config {String} shareContent 描述
* @p-config {String} shareTitle 分享的标题
* 
* function sentShareImage 给分析图片赋值，默认body里第一张，。。。动态加载以后调用
*/
function WxShare(options){
	if(options==null){
		options={};
	};
	this.appid="wx176df9e9feef3e36"; 
	this.shareTitle=options.shareTitle||document.title;
	this.shareImage=options.shareImage||"";
	this.shareLink=options.shareLink||window.location.href;
	this.shareContent=options.shareContent||document.title;
	this.shareWindwoWidth=options.shareWindwoWidth||"640";
	this.shareWindwoHeight=options.shareWindwoHeight||"640";
	this.hideOptionMenu=options.hideOptionMenu||false;
	this.isNotFx=options.isNotFx||false;
	this.isSendIntergal=options.isSendIntergal||false;
	//对分享链接处理，加标记finxiang=1
	if(!(this.shareLink.indexOf('?')>1)){
		this.shareLink+="?1=1";
		}
	if(this.shareLink.indexOf("&code")>1){//微信特殊url处理
		var s=this.shareLink.split("?");
		this.shareLink=s[0]+"?fenxiang=1&shopId="+_shopId+"&openId="+_openId;//依赖openId.js
	}
	if(!(this.shareLink.indexOf("&fenxiang")>1)){
		this.shareLink+="&fenxiang=1";
	}
	this.init(this);
}

WxShare.prototype.init=function(obj){ //初始化
	//判断是否启用分享送积分
	if(obj.isSendIntergal){
		obj.sendShareIntegral();
	}
	
	//初始化微信内置分享
	document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
		if(obj.hideOptionMenu){ //判断是否隐藏右上角按钮
            WeixinJSBridge.call('hideOptionMenu');
        }else{
            WeixinJSBridge.call('showOptionMenu');
            if(!obj.isNotFx){//是否重写分享链接
        // 发送给好友  
        WeixinJSBridge.on('menu:share:appmessage', function(argv){  
        	obj.shareFriend();  
            });  
  
        // 分享到朋友圈  
        WeixinJSBridge.on('menu:share:timeline', function(argv){  
        	obj.shareTimeline();  
            });  
  
        // 分享到微博  
        WeixinJSBridge.on('menu:share:weibo', function(argv){  
        	obj.shareWeibo();  
            });
        }
            
        }
        }, false);   
};
WxShare.prototype.sentShareImage=function(imgeUrl){
	
	if(imgeUrl==null||imgeUrl==undefined){
		this.shareImage = $("body img").eq(0).attr("src");
	}else{
	this.shareImage = imgeUrl;
	}
};

WxShare.prototype.callBack=function(res){//回调函数
};

WxShare.prototype.shareFriend=function(){
	WeixinJSBridge.invoke('sendAppMessage',{  
        "appid":this.appid ,  
        "img_url": this.shareImage,  
        "img_width": this.shareWindwoWidth,  
        "img_height": this.shareWindwoHeight,  
        "link": this.shareLink,  
        "desc": this.shareContent,  
        "title": this.shareTitle  
        }, function(res) {  
        	this.callBack(res);
        });  
};

WxShare.prototype.shareWeibo=function() {  
    WeixinJSBridge.invoke('shareWeibo',{  
        "content": this.shareContent,  
        "url": this.shareLink,  
        }, function(res) {  
        	this.callBack(res);
        });  
};  

WxShare.prototype.shareTimeline=function(){
	WeixinJSBridge.invoke('shareTimeline',{  
        "img_url": this.shareImage,  
        "img_width":this.shareWindwoWidth,  
        "img_height": this.shareWindwoHeight,  
        "link": this.shareLink,  
        "desc": this.shareContent,  
        "title": this.shareContent||this.shareTitle  
        }, function(res) {  
        	this.callBack(res);
        });  
};


WxShare.prototype.sendShareIntegral=function(){
	var fenxiang = getIdByName("fenxiang");
	if(fenxiang==1){
		var url = 	window.location.href;
		var heads = new Array("openId","url","ip","shopId");
		var datas = new Array(_openId,url,"0",_shopId);
		var parser = new Object();
		var jsonParserStr = null;
		if (IsNotEmpty(datas)){
			addToParser(heads, datas, "add" , parser);
			jsonParserStr =  JSON.stringify(parser);
		}
		
		$.ajax({type : "post",
			data:{'data':jsonParserStr},
			datatype : "json",
			url : "../../../shareDiscuss/insert/insertInfo", 
			success:function(data) {
			}	
			});
	}
};
